{extend name="common/layout" /}
{block name="head"}
<link rel="stylesheet" href="__STATIC__/common/css/jquery-ui.css" media="all">
<script type="text/javascript" src="__STATIC__/common/js/jquery-ui.js"></script>
<style type="text/css">
    .alip-cloud,.cloud-aws,.cloud-alip,.aws-cloud{display: none;}
</style>
{/block}
{block name="main"}
<div class="admin-main fadeInUp animated" ng-app="hd" ng-controller="ctrl">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>{:lang('Network Open Application')}</legend>
    </fieldset>
    <blockquote class="layui-elem-quote layui-text">
      <p><b>{:lang('Relevant instructions:')}</b></p>
      <p>{:lang('Please fill in the following information form, number (*) are required.')}</p>
      <p>{:lang('After the application is submitted, it will take 1 working days to complete the audit, and the result will be notified to you.')}</p>
    </blockquote>
    <form class="layui-form nerwork-like" id="_form">
        <input type="hidden" name="id" value="{$row['id']}">
        <input type="hidden" name="cat" value="{$cat}">
        <input type="hidden" name="is_sn" value="{$row['is_sn']}">
        <input type="hidden" name="form_type" value="{$form_type}">
        <div class="layui-form-item">
            <label class="layui-form-label">* {:lang('Line Name')}</label>
            <div class="layui-input-4">
                <input type="text" name="name" value="{$row['name']}" lay-verify="required" placeholder="{:lang('Please Enter The Name')}" class="layui-input">
            </div>
        </div>
        
        <div class="layui-form-item">
            <label class="layui-form-label">* {:lang('Local Access')}</label>
            <div class="layui-input-4">
              <select name="type" lay-filter="type" lay-verify="required" id="_type">
                <option value="">{:lang('Please Select Type')}</option>
                <?php foreach($types as $index=>$type):?>
                    <option value="{$index}" <?php if($row['type']==$index){echo "selected";}?> >{$type}</option>
                <?php endforeach;?>
              </select>
            </div>
        </div>
        <!--公司机构&数据中心(私有云)类型表单-->
        <div class="type type-company">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">* {:lang('Region')}</label>
                    <div class="layui-input-inline">
                      <select name="country_id" lay-filter="countryId" data-value="{$row['city_id']}" data-aid="#city_id">
                        <option value="">{:lang('Please Choose')}</option>
                        <?php foreach($popArr as $pop):?>
                        <option value="{$pop['id']}" <?php if($pop['id'] == $row['country_id']){echo "selected";}?> >{$pop['name']}</option>
                        <?php endforeach;?>
                      </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">* {:lang('City')}</label>
                    <div class="layui-input-inline" >
                        <select name="city_id" data-value="{$row['pop_id']}" data-pid="0" data-aid="#pop_id" id="city_id" lay-filter="cityId">
                        </select>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">* {:lang('POP')}</label>
                    <div class="layui-input-inline">
                        <select name="pop_id" id="pop_id" lay-filter="popId">
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">* {:lang('End Access Address')}</label>
                    <div class="layui-input-inline">
                        <input type="text" name="access_addr" value="{$row['access_addr']}" placeholder="{:lang('Fill in the detailed address of the organization / data center')}" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                     <label class="layui-form-label">* {:lang('End Network')}</label>
                    <div class="layui-input-inline">
                        <input type="text" name="local_network" value="{$row['local_network']}" placeholder="{:lang('Format:192.168.24.0/24')}" class="layui-input">
                    </div>
                </div>
            </div>
        </div>
        <!--end-->
        <!--公有云-->
        <div class="type type-publc">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">* {:lang('Gong Youyun')}</label>
                    <div class="layui-input-inline">
                      <select name="local_cloud_id" id="local_cloud_id"  data-value="{$row['country_id']}" data-aid="#localcloudaddrid" lay-filter="localcloudid">
                        <option value="">{:lang('Please Choose')}</option>
                        <?php foreach($clouds as $cloud):?>
                        <option value="{$cloud['id']}" <?php if($cloud['id']==$row['local_cloud_id']){echo "selected";}?> >{$cloud['name']}</option>
                        <?php endforeach;?>
                      </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">* {:lang('Local Cloud Connection Area')}</label>
                    <div class="layui-input-inline">
                      <select name="cloud_country" id="localcloudaddrid" data-value="{$row['city_id']}" data-aid="#cloud_city" lay-filter="localcloudaddrid" >
                        <option value="">{:lang('Please Choose')}</option>
                      </select>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">* {:lang('Local Access City')}</label>
                    <div class="layui-input-inline">
                      <select name="cloud_city" id="cloud_city" data-value="{$row['cloud_conter']}" data-aid="#cloud_conter" lay-filter="cloudCity">
                        <option value="">{:lang('Please Choose')}</option>
                        
                      </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label"> {:lang('Cloud Data Center')}</label>
                    <div class="layui-input-inline">
                      <select name="cloud_conter"  data-value="{$row['cloud_conter']}" id="cloud_conter">
                        <option value="">{:lang('Please Choose')}</option>
                      </select>
                    </div>
                </div>
            </div>
            <!--根据云接入类型呈现以下信息 阿里云&腾讯云-->
            <div class="cloud-alip">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label" id="account_label1">* 
                            <?php if($row['local_cloud_id'] == 3739):?>
                                {:lang('Pairing key')}：
                            <?php elseif($row['local_cloud_id'] == 3738):?>
                                {:lang('Service Key')}： 
                            <?php elseif($row['local_cloud_id'] == 3742):?>
                                {:lang('Account')}：
                            <?php else:?>
                                {:lang('Account ID')}：
                            <?php endif;?>
                        </label>
                        <div class="layui-input-inline">
                            <input type="text" name="local_cloud_userid" value="{$row['local_cloud_userid']}" placeholder="{:lang('Please enter the account ID')}" class="layui-input">
                        </div>
                    </div>
                </div>
                <!--華爲云，新增 订单编号VPC ID，VPC所在可用区~-->
                <div id='cloud-huawei1' {$row['local_cloud_id'] == 3742 ? '' : "style='display: none;'"} >
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">* {:lang('Order ON.')}</label>
                            <div class="layui-input-inline">
                                <input type="text" name="orderId1" value="{$row['orderId1']}" placeholder="{:lang('Please input order number.')}" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">* {:lang('VPC ID')}</label>
                            <div class="layui-input-inline">
                                <input type="text" name="VPCID1" value="{$row['VPCID1']}" placeholder="{:lang('Please input VPC ID')}" class="layui-input">
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">* {:lang('VPC available area')}</label>
                            <div class="layui-input-inline">
                              <input type="text" name="VPC1" value="{$row['VPC1']}" placeholder="{:lang('Please enter the VPC availability area.')}" class="layui-input">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!--阿里云&腾讯云 end-->
            <!--AWS-->  
            <div class="aws-cloud">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">* {:lang('Account ID')}</label>
                        <div class="layui-input-inline">
                            <input type="text" name="aws_local_cloud_userid" value="{$row['local_cloud_userid']}" placeholder="{:lang('Please enter the account ID')}" class="layui-input">
                        </div>
                    </div>
                    
                </div>  
                <!-- <div class="layui-form-item">
                   
                    <div class="layui-inline">
                        <label class="layui-form-label">* {:lang('AccessID')}</label>
                        <div class="layui-input-inline">
                            <input type="text" name="local_aws_accessID" value="{$row['local_aws_accessID']}" placeholder="{:lang('Please enter the AccessID')}" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label ">* {:lang('SecrectKey')}</label>
                        <div class="layui-input-inline">
                            <input type="text" name="local_aws_secrectKey" value="{$row['local_aws_secrectKey']}" placeholder="{:lang('Please enter the SecrectKey')}" class="layui-input">
                        </div>
                    </div>
                </div>   -->
            </div> 
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label" id="oth_local_network_label">* {:lang('End Network')}</label>
                    <div class="layui-input-inline">
                        <input type="text" name="oth_local_network" value="{$row['local_network']}" placeholder="{:lang('Format:192.168.24.0/24')}" class="layui-input">
                    </div>
                </div>
            </div>
        </div>
        <!--AWS end-->
        <!--对端接入start-->
        <div class="layui-form-item">
            <label class="layui-form-label">* {:lang('End-to-end access')}</label>
            <div class="layui-input-4">
              <select name="endtype" lay-filter="endtype" lay-verify="required">
                <option value="">{:lang('Please Select Type')}</option>
                <?php foreach($types as $index=>$type):?>
                    <option value="{$index}" <?php if($row['endtype']==$index){echo "selected";}?> >{$type}</option>
                <?php endforeach;?>
              </select>
            </div>
        </div>
        <!--对端公有云的form-->
        <div class="etype etype-publc" <?php if($row['endtype'] !=3):?> style="display: none; <?php endif;?>">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">* {:lang('End Cloud Type')}</label>
                    <div class="layui-input-inline">
                      <select name="endcloudid" data-aid="#endcloudaddrid" data-value="{$row['ecountry_id']}" lay-filter="endcloudid" id="_endcloudid">
                        <option value="">{:lang('Please Choose')}</option>
                        <?php foreach($clouds as $cloud):?>
                        <option value="{$cloud['id']}" <?php if($cloud['id'] == $row['endcloudid']){echo "selected";} ?>>{$cloud['name']}</option>
                        <?php endforeach;?>
                      </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">* {:lang('End Cloud Area')}</label>
                    <div class="layui-input-inline">
                      <select name="endcloudaddrid"  id="endcloudaddrid" data-value="{$row['ecity_id']}"  lay-filter="endCloudaddrid" data-aid="#ecloud_city">
                        <option value="">{:lang('Please Choose')}</option>
                      </select>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">* {:lang('Peer Access City')}</label>
                    <div class="layui-input-inline">
                      <select name="ecloud_city" id="ecloud_city" data-value="{$row['ecloud_conter']}" data-aid="#ecloud_conter" lay-filter="ecloudCity">
                        <option value="">{:lang('Please Choose')}</option>
                        
                      </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label"> {:lang('Cloud Data Center')}</label>
                    <div class="layui-input-inline">
                      <select name="ecloud_conter"  id="ecloud_conter">
                        <option value="">{:lang('Please Choose')}</option>
                      </select>
                    </div>
                </div>
            </div>
            <!--根据云接入类型呈现以下信息 阿里云&腾讯云-->
            <div class="alip-cloud">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label" id="account_label2">*
                        <?php if($row['endcloudid'] == 3739):?>
                            {:lang('Pairing key')}：
                        <?php elseif($row['endcloudid'] == 3738):?>
                            {:lang('Service Key')}： 
                        <?php elseif($row['endcloudid'] == 3742):?>
                            {:lang('Account')}：
                        <?php else:?>
                            {:lang('Account ID')}：
                        <?php endif;?>
                        </label>
                        <div class="layui-input-inline">
                            <input type="text" name="end_userid" value="{$row['end_userid']}" placeholder="{:lang('Please enter the account ID')}" class="layui-input">
                        </div>
                    </div>
                </div>
                <!--華爲云，新增 订单编号VPC ID，VPC所在可用区~-->
                <div id='cloud-huawei2' {$row['endcloudid'] == 3742 ? '' : "style='display: none;'"} >
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">* {:lang('Order ON.')}</label>
                            <div class="layui-input-inline">
                                <input type="text" name="orderId2" value="{$row['orderId2']}" placeholder="{:lang('Please input order number.')}" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">* {:lang('VPC ID')}</label>
                            <div class="layui-input-inline">
                                <input type="text" name="VPCID2"  value="{$row['VPCID2']}" placeholder="{:lang('Please input VPC ID')}" class="layui-input">
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">* {:lang('VPC available area')}</label>
                            <div class="layui-input-inline">
                              <input type="text" name="VPC2" value="{$row['VPC2']}" placeholder="{:lang('Please enter the VPC availability area.')}" class="layui-input">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!--阿里云&腾讯云 end-->
            <!--AWS-->  
            <div class="cloud-aws">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">* {:lang('Account ID')}</label>
                        <div class="layui-input-inline">
                            <input type="text" name="aws_end_userid" value="{$row['end_userid']}" placeholder="{:lang('Please enter the account ID')}" class="layui-input">
                        </div>
                    </div>
                    
                </div>  
                <!-- <div class="layui-form-item">
                    
                    <div class="layui-inline">
                        <label class="layui-form-label">* {:lang('AccessID')}</label>
                        <div class="layui-input-inline">
                            <input type="text" name="end_aws_accessID" value="{$row['end_aws_accessID']}" placeholder="{:lang('Please enter the AccessID')}" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label ">* {:lang('SecrectKey')}</label>
                        <div class="layui-input-inline ">
                            <input type="text" name="end_aws_secrectKey"  value="{$row['end_aws_secrectKey']}" placeholder="{:lang('Please enter the SecrectKey')}" class="layui-input">
                        </div>
                    </div>
                </div>   -->
            </div> 
            <!--AWS end-->
            <div class="layui-form-item">  
                <div class="layui-inline">
                    <div class="layui-inline">
                        <label class="layui-form-label" id="end_network_label">* {:lang('End-to-end Network')}</label>
                        <div class="layui-input-inline">
                            <input type="text" name="end_network"  value="{$row['end_network']}" placeholder="{:lang('Format:192.168.24.0/24')}" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--公司机构&数据中心(私有云)类型表单-->
        <div class="etype etype-company" <?php if($row['endtype'] ==3):?>style="display: none;"<?php endif;?>>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">* {:lang('Region')}</label>
                    <div class="layui-input-inline">
                      <select name="ecountry_id" lay-filter="ecountryId" data-value="{$row['ecity_id']}" data-aid="#ecity_id">
                        <option value="">{:lang('Please Choose')}</option>
                        <?php foreach($popArr as $pop):?>
                        <option value="{$pop['id']}" <?php if($pop['id'] == $row['ecountry_id']){echo "selected";}?>  >{$pop['name']}</option>
                        <?php endforeach;?>
                      </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">* {:lang('City')}</label>
                    <div class="layui-input-inline" >
                        <select name="ecity_id" data-pid="0" data-aid="#epop_id" data-value="{$row['epop_id']}" id="ecity_id" lay-filter="ecityId">
                        </select>
                    </div>
                </div>

            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">* {:lang('POP')}</label>
                    <div class="layui-input-inline">
                      <select name="epop_id" id="epop_id" lay-filter="epopId">
                        <option value="">{:lang('Please Choose')}</option>
                        
                      </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">* {:lang('End to end access address')}</label>
                    <div class="layui-input-inline">
                        <input type="text" value="{$row['eaccess_addr']}" name="eaccess_addr" placeholder="{:lang('Fill in the detailed address of the organization / data center')}" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                
                <div class="layui-inline">
                     <label class="layui-form-label ">* {:lang('End-to-end Network')}</label>
                    <div class="layui-input-inline">
                        <input type="text" value="{$row['end_network']}"  name="elocal_network" placeholder="{:lang('Format:192.168.24.0/24')}" class="layui-input">
                    </div>
                </div>
            </div>
        </div>    
        
            <!--费用-->
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">* {:lang('Bandwidth')}</label>
                    <div class="layui-input-inline" style="position: relative;width: 500px;">
                    <div id="mslider">
                        <div id="custom-handle" class="ui-slider-handle">
                            <span></span>
                        </div>
                     </div>
                    <span class="broadbandinput">
                        <label class="broadband-label">
                            <input type="test" value="{$row['broadband']}" id="_broadband" name="broadband" class="broadband">
                            <span class="autobtn"></span>
                            <span class="_add"></span>
                            <span class="_min"></span>
                        </label> 
                        Mbps
                    </span> 
<!--                         <input type="text" name="broadband" lay-verify="required" placeholder="{:lang('请输入带宽(Mbps)')}" class="layui-input">
-->             </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">*  {:lang('Purchase Time')}</label>
                    <div class="layui-input-inline">
                       <select name="daylength"  lay-filter="_daylength" lay-verify="required" id="endcloudaddrid">
                           <option value="">{:lang('Please Choose')}</option>
                           <?php foreach($daLength as $dindex=>$d):?>
                            <option value="{$dindex}" <?php if($row['daylength'] == $dindex){echo "selected";}?> >{$d}</option>
                            <?php endforeach;?>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">{:lang('Planned opening time')}</label>
                    <div class="layui-input-inline">
                        <input type="text" id="plan_time" readonly="" value="{$row['plan_time']}" name="plan_time" placeholder="{:lang('Planned opening time')}" class="layui-input">
                    </div>
                </div>
            </div>
        <!--end-->
        <!--图片-->
        <!-- <div class="layui-form-item">
            <label class="layui-form-label">* {:lang('Media')}</label>
            <div class="layui-input-4" style="position: relative;">
                <input type="text" name="media" placeholder="" value="{$row['media']}"  lay-verify="required" id="_media" class="layui-input" readonly="" >
                <button type="button" class="layui-btn layui-btn-primary" id="_mediaBtn" style="position: absolute;right: 0px;top:0"><i class="icon icon-upload3"></i>{:lang('Upload')}</button>
                <?php if(!empty($row['media'])):?>
                    <p id="_media_view"><img src="{$row['media']}"style="width:100px;max-height:100px;margin-top:3px;" /></p>
                <?php endif;?>
            </div>
        </div> -->
         <!--备注-->
       
        <div class="layui-form-item">
            <label class="layui-form-label">{:lang('Remarks')}</label>
            <div class="layui-input-4">
                <textarea placeholder="{:lang('Please enter content')}"  id="_create_remarks" name="remarks" class="layui-input" style="width:100%;height: 50px;">{$row['remarks']}</textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <div class="layui-input-inline" style="width: 100px;">
                <button type="button" class="layui-btn" lay-submit="" lay-filter="submit">{:lang('submit')}</button>
            </div>
            <div class="layui-form-mid layui-word-aux" id="price-money">
                {:lang('Configuration Cost:')}<span class='price-money'>{$row['total']} / {:lang('Month')}</span>
            </div>
        </div>
    </form>
</div>
{/block}
{block name="footer"}
<script>
    layui.use(['form', 'layer','laydate','upload'], function () {
        var form = layui.form, layer = layui.layer,$= layui.jquery,laydate = layui.laydate,upload = layui.upload;
        form.on('submit(submit)', function (data) {
            loading = layer.load(1,{shade:[0.1,'#fff']});
            // 提交到方法 默认为本身
            //data.field.id = $scope.field.id;
            $.post("{:U('create')}", data.field, function (res) {
                layer.close(loading);
                if (res.code > 0) {
                    layer.msg(res.msg, {time: 1800, icon: 1}, function () {
                        location.href = res.url;
                    });
                } else {
                    layer.msg(res.msg, {time: 1800, icon: 2});
                }
            });
        });
        /*绑定本端接入类型（公司机构、数据中心（私有云）、公有云）*/
        form.on("select(type)",function(obj){
            if(obj.value == 3){  //公有云
               $(".type").hide(); 
               $(".type-publc").show(); 
            }else{
                $(".type").hide();
                $(".type-company").show(); 
                 
            }
        })
        /*默认类型*/
        if($("#_type").val() == 3){
            $(".type").hide(); 
            $(".type-publc").show(); 
        }else{
            $(".type").hide();
            $(".type-company").show(); 
        }
        /*本端公有云（云列表）*/
        form.on("select(localcloudid)",function(obj){
            var doem = obj.elem.dataset.aid;
            var value =  obj.elem.dataset.value;
            if(obj.value > 0){
                if(obj.value == 3737){  //aws云
                    $(".cloud-alip").hide();
                    $(".aws-cloud").show();
                }else{
                    $(".cloud-alip").show();
                    $(".aws-cloud").hide();
                }
                $(doem).html("<option value=''>{:lang('Please Choose')}</option>");
                $.post("{:U('cloud/getClouList')}",{pid:obj.value},function(res){
                    if(res.code == 1){
                        $.each(res.items,function(i,item){
                            if(value == item.id){
                                $(doem).append("<option value='"+item.id+"' selected >"+item.name+"</option")
                            }else{
                                $(doem).append("<option value='"+item.id+"'>"+item.name+"</option")
                            }
                        })
                        form.render();
                        if(parseInt(value) > 0){
                            setSelectedclick('cloud_country',value);
                        }
                    }
                    
                },'json')
            }
            $("#cloud-huawei1").hide();
            //$("#oth_local_network_label").text($("#oth_local_network_label").text().replace("*",""));
            /*設置label*/
            if(obj.value == 3739){  //Google
                $("#account_label1").text("* Pairing key")
                $("input[name='local_cloud_userid'").attr('placeholder',"{:lang('Please enter Pairing key')}")
            }else if(obj.value == 3738){ //Azure
                $("#account_label1").text("* Service Key");
                $("input[name='local_cloud_userid'").attr('placeholder',"{:lang('Please enter the service key')}")
            }else if(obj.value == 3742){ //華爲云
                $("#cloud-huawei1").show();
                $("#account_label1").text("* Account")
                $("input[name='local_cloud_userid'").attr('placeholder',"{:lang('Please enter the name of the account')}")
                //$("#oth_local_network_label").text("*"+$("#oth_local_network_label").text());
            }else{  //其他
                $("#account_label1").text("* {:lang('Account ID')}")
                $("input[name='local_cloud_userid'").attr('placeholder',"{:lang('Please enter the account ID')}")
            }
        })
        
        /*地区*/
        form.on("select(localcloudaddrid)",function(obj){
            var doem = obj.elem.dataset.aid;
            var value =  obj.elem.dataset.value;
            $("#cloud_city,#cloud_conter").html("<option value=''>{:lang('Please Choose')}</option>");
            form.render();
            $.post("{:U('cloud/getCloudCity')}",{country_id:obj.value,cloud_id:$("select[name='local_cloud_id']").val()},function(res){
                $(doem).html("<option value=''>{:lang('Please Choose')}</option>");
                if(res.code == 1){
                    $.each(res.items,function(i,item){
                        if(value  == item.id){
                            $(doem).append("<option value='"+item.id+"' selected >"+item.name+"</option")
                        }else{
                             $(doem).append("<option value='"+item.id+"'>"+item.name+"</option")
                        }
                    })
                }
                form.render();
                if(parseInt(value) > 0){
                    setSelectedclick('cloud_city',value);
                }
            },'json')
        })
        /*本端城市*/
        form.on("select(cloudCity)",function(obj){
            var doem = obj.elem.dataset.aid;
            var value =  obj.elem.dataset.value;
            $("#cloud_conter").html("<option value=''>{:lang('Please Choose')}</option>");
            form.render();
            $.post("{:U('cloud/getCloudItems')}",{city_id:obj.value,cloud_id:$("select[name='local_cloud_id']").val(),country_id:$("#localcloudaddrid").val()},function(res){
                $(doem).html("<option value=''>{:lang('Please Choose')}</option>");
                if(res.code == 1){
                    $.each(res.items,function(i,item){
                        if(value  == item.id){
                            $(doem).append("<option value='"+item.id+"' selected >"+item.name+"</option")
                        }else{
                             $(doem).append("<option value='"+item.id+"'>"+item.name+"</option")
                        }
                       
                    })
                     _alculator({
                        url:"{:U('query')}",
                        data:$("#_form").serializeArray(),
                        notice:"{:lang('The cost is being calculated....')}"
                    })
                }
                form.render();
            },'json')
        })
        setSelectedclick('local_cloud_id',$("select[name='local_cloud_id']").val());
        /*end 本端公有云*/
        /*对端公有云（云列表）*/
        form.on("select(endcloudid)",function(obj){
            var doem = obj.elem.dataset.aid;
            var value =  obj.elem.dataset.value;
            if(obj.value > 0){
                if(obj.value == 3737){  //aws云
                    $(".alip-cloud").hide();
                    $(".cloud-aws").show();
                }else{
                    $(".alip-cloud").show();
                    $(".cloud-aws").hide();
                }
                $.post("{:U('cloud/getClouList')}",{pid:obj.value},function(res){
                    if(res.code == 1){
                        $(doem).html("<option value=''>{:lang('Please Choose')}</option>");
                        $.each(res.items,function(i,item){
                            if(value == item.id){
                                $(doem).append("<option value='"+item.id+"' selected >"+item.name+"</option")
                            }else{
                                $(doem).append("<option value='"+item.id+"'>"+item.name+"</option")
                            }
                        })
                        form.render();
                        if(parseInt(value) > 0){
                            setSelectedclick('endcloudaddrid',value);
                        }
                    }
                },'json')
            }
            $("#cloud-huawei2").hide();
            //$("#end_network_label").text($("#end_network_label").text().replace("*",""))
            /*設置label*/
            if(obj.value == 3739){  //Google
                $("#account_label2").text("* Pairing key")
                $("input[name='end_userid'").attr('placeholder',"{:lang('Please enter the Pairing key')}")
            }else if(obj.value == 3738){ //Azure
                $("#account_label2").text("* Service Key")
                $("input[name='end_userid'").attr('placeholder',"{:lang('Please enter the service key')}")
            }else if(obj.value == 3742){ //華爲云
                $("#cloud-huawei2").show();
                $("#account_label2").text("* Account")
                $("input[name='end_userid'").attr('placeholder',"{:lang('Please enter the name of the account')}")
                //$("#end_network_label").text("*"+$("#end_network_label").text())
            }else{  //其他
                $("#account_label2").text("* {:lang('Account ID')}")
                $("input[name='end_userid'").attr('placeholder',"{:lang('Please enter the account ID')}")
            }
        })
        /*地区*/
        form.on("select(endCloudaddrid)",function(obj){
            var doem = obj.elem.dataset.aid;
            var value =  obj.elem.dataset.value;
            $("#ecloud_city,#ecloud_conter").html("<option value=''>{:lang('Please Choose')}</option>");
            form.render();
            $.post("{:U('cloud/getCloudCity')}",{country_id:obj.value,cloud_id:$("select[name='endcloudid']").val()},function(res){
                $(doem).html("<option value=''>{:lang('Please Choose')}</option>");
                if(res.code == 1){
                    $.each(res.items,function(i,item){
                        if(value == item.id){
                            $(doem).append("<option value='"+item.id+"' selected >"+item.name+"</option")
                        }else{
                            $(doem).append("<option value='"+item.id+"'>"+item.name+"</option")
                        }
                    })
                }
                form.render();
                if(parseInt(value) > 0){
                    setSelectedclick('ecloud_city',value);
                }
            },'json')
        })
        /*对端城市*/
        form.on("select(ecloudCity)",function(obj){
            var doem = obj.elem.dataset.aid;
            var value =  obj.elem.dataset.value;
            $("#ecloud_conter").html("<option value=''>{:lang('Please Choose')}</option>");
            form.render();
            $.post("{:U('cloud/getCloudItems')}",{city_id:obj.value,cloud_id:$("select[name='endcloudid']").val(),country_id:$("#endcloudaddrid").val()},function(res){
                $(doem).html("<option value=''>{:lang('Please Choose')}</option>");
                if(res.code == 1){
                    $.each(res.items,function(i,item){
                        if(value == item.id){
                            $(doem).append("<option value='"+item.id+"' selected >"+item.name+"</option")
                        }else{
                            $(doem).append("<option value='"+item.id+"'>"+item.name+"</option")
                        }
                    })
                     _alculator({
                        url:"{:U('query')}",
                        data:$("#_form").serializeArray(),
                        notice:"{:lang('The cost is being calculated....')}"
                    })
                }
                form.render();
            },'json')
        })
         setSelectedclick('endcloudid',$("select[name='endcloudid']").val());
         /*公有云 end*/
         /*本端pop点切换*/
         form.on("select(countryId)",function(obj){
            var doem = obj.elem.dataset.aid;
            var value = obj.elem.dataset.value;
            $(doem).attr('data-pid',obj.value);
            $(doem).html("<option value=''>{:lang('Please Choose')}</option>");
            $("#pop_id").html("<option value=''>{:lang('Please Choose')}</option>");
            form.render();
            loading =layer.load(1, {shade: [0.1,'#fff']});
            $.post("{:U('pop/popList')}",{pid:obj.value},function(res){
                layer.close(loading);
                //$("input[name='access_addr']").val('')
                if(res.code == 1){
                    $.each(res.items,function(i,item){
                        if(value == item.id){
                            $(doem).append("<option value='"+item.id+"' selected >"+item.name+"</option")
                        }else{
                            $(doem).append("<option value='"+item.id+"'>"+item.name+"</option")
                        }
                        
                    })
                }
                form.render();
                if(parseInt(value) > 0){
                    setSelectedclick('city_id',value);
                }
            },'json')
        })
        /*pop点切换*/
        form.on("select(cityId)",function(obj){
            var doem = obj.elem.dataset.aid;
            var value = obj.elem.dataset.value;
            $(doem).html("<option value=''>{:lang('Please Choose')}</option>");
            form.render();
            
            $.post("{:U('pop/popItems')}",{city_id:obj.value,area_id:obj.elem.dataset.pid},function(res){
                layer.close(loading);
                //$("input[name='access_addr']").val('');
                if(res.code == 1){
                    $.each(res.items,function(i,item){
                        if(value == item.id){
                            $(doem).append("<option value='"+item.id+"' selected data-address='"+item.address+"'>"+item.name+"</option")
                        }else{
                            $(doem).append("<option value='"+item.id+"' data-address='"+item.address+"'>"+item.name+"</option")
                        }
                        
                    })
                    
                }
                form.render();

            },'json')
        })
        form.on("select(popId)",function(obj){
            var _addres = $("#pop_id").find("option[value='"+obj.value+"']").data('address');
            $("input[name='access_addr']").val(_addres)
             _alculator({
                url:"{:U('query')}",
                data:$("#_form").serializeArray(),
                notice:"{:lang('The cost is being calculated....')}"
            })
            
        })
        setSelectedclick('country_id',$("select[name='country_id']").val());
         /*对端pop点接入*/
        form.on("select(ecountryId)",function(obj){
            var doem = obj.elem.dataset.aid;
            $(doem).attr('data-pid',obj.value);
            var value = obj.elem.dataset.value;
            $(doem).html("<option value=''>{:lang('Please Choose')}</option>");
            $("#epop_id").html("<option value=''>{:lang('Please Choose')}</option>");
            form.render();
            $.post("{:U('pop/popList')}",{pid:obj.value},function(res){
                //$("input[name='eaccess_addr']").val('')
                if(res.code == 1){
                    $.each(res.items,function(i,item){
                        if(value == item.id){
                            $(doem).append("<option value='"+item.id+"' selected >"+item.name+"</option")
                        }else{
                             $(doem).append("<option value='"+item.id+"'>"+item.name+"</option")
                        }
                        
                    })
                }
                form.render();
                if(parseInt(value) > 0){
                    setSelectedclick('ecity_id',value);
                }
            },'json')
        })
        /*pop点切换*/
        form.on("select(ecityId)",function(obj){
            var doem = obj.elem.dataset.aid;
            var value = obj.elem.dataset.value;
            $(doem).html("<option value=''>{:lang('Please Choose')}</option>");
            form.render();
            $.post("{:U('pop/popItems')}",{city_id:obj.value,area_id:obj.elem.dataset.pid},function(res){
                //$("input[name='eaccess_addr']").val('');
                if(res.code == 1){
                    $.each(res.items,function(i,item){
                        if(value == item.id){
                            $(doem).append("<option value='"+item.id+"' data-address='"+item.address+"' selected >"+item.name+"</option")
                        }else{
                            $(doem).append("<option value='"+item.id+"' data-address='"+item.address+"'>"+item.name+"</option")
                        }
                        
                    })
                    
                }
                form.render();
            },'json')
        })
        form.on("select(epopId)",function(obj){
            var _addres = $("#epop_id").find("option[value='"+obj.value+"']").data('address');
            $("input[name='eaccess_addr']").val(_addres)
             _alculator({
                url:"{:U('query')}",
                data:$("#_form").serializeArray(),
                notice:"{:lang('The cost is being calculated....')}"
            })
        })
        /*时间切换*/
        form.on("select(_daylength)",function(obj){
            /*计算价钱*/
            _alculator({
                url:"{:U('query')}",
                data:$("#_form").serializeArray(),
                notice:"{:lang('The cost is being calculated....')}"
            })
        })
        setSelectedclick('ecountry_id',$("select[name='ecountry_id']").val());
        //日期
        laydate.render({
            elem: '#_date',
            lang: 'en'
        });
        /*計劃開通時間*/
        laydate.render({
            elem: '#plan_time',
            lang: 'en',
            min:+1
        });
        setSlideMb(function(){
             _alculator({
                url:"{:U('query')}",
                data:$("#_form").serializeArray(),
                notice:"{:lang('The cost is being calculated....')}"
            })
        });
        //普通图片上传
        var loading = null;
        var uploadInst = upload.render({
            elem: '#_mediaBtn'
            ,url: '{:url("UpFiles/upload")}'
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                loading =layer.load(1, {shade: [0.1,'#fff']});
            }
            ,done: function(res){
                layer.close(loading);  
                //上传成功
                if(res.code>0){
                    $('#_media').val(res.url);
                    $('#_media').parent().find("#_media_view").remove();
                    $('#_media').parent().append('<p id="_media_view"><img src="'+res.url+'"style="width:100px;max-height:100px;margin-top:3px;" /></p>')
                }else{
                    //如果上传失败
                    return layer.msg("{:lang('Upload failure')}");
                }
            }
            ,error: function(){
                layer.close(loading);  
                //演示失败状态，并实现重传
                return layer.msg("{:lang('Upload failure')}");
            }
        });
    });
</script>
{/block}